import c_remove from '@dfeidao/atom-web/cookie/remove';
import remove from '@dfeidao/atom-web/global/remove';
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import direct from '@dfeidao/atom-web/url/direct-to';

export default async function a003(fd: IFeidaoAiBrowserComponent) {
	const user_no = get(fd, 'user_no') as string;
	const res = await nodejs('common/zjc-000002/s002', { user_no }) as {
		res: { code: number; }
	};
	if (res.res.code === 1) {
		// remove('sessionid');
		remove('user_no');
		c_remove('uk');
		c_remove('sessionid');
		// return;
		const page_name = fd.data.url.match(/.*\/((.*?)\.html)/)[1];
		const params = fd.data.url.includes('?') ? fd.data.url.substr(fd.data.url.indexOf('?')) : '';
		const backurl = {
			backurl: './' + page_name + params
		};
		direct('./login.html', backurl);
	}



}
